#ifndef __INDEX_H__
#define __INDEX_H__

#include<math.h>
#include "Settings.h"

//A 0, C 1, G 2, T 3
struct LookupTable {

	unsigned int tableSize;
 	unsigned int * table;

//	void LoadLookupTable(const char * fileName, const int tableSize);
};
void LoadLookupTable(LookupTable *lookupTable, const char * fileName, const int mtableSize);
void BuildDeviceOccCountMap(char * occCountMap);
struct BWT
{
//public:
	unsigned int * bwtCode;
	unsigned int * saValue;
	unsigned int * occValue;
	unsigned int * occMajorValue;
	unsigned int * GPUOccValue;
//	unsigned int * myoccValue[ALPHABET_SIZE];
	unsigned int * countValue;
	
	unsigned int saLength;
	unsigned int textLength;

	unsigned int bwtSizeInWord;
	unsigned int occSizeInWord;
	unsigned int GPUOccValueInWord;
	unsigned int occMajorSizeInWord;
	unsigned int saValueSizeInWord;

	unsigned int inverseSa0;
	unsigned int saInterval;

	LookupTable * lookupTable;

	/*
	~BWT()
	{
		delete[] occValue;	
		delete[] occMajorValue;
		delete[] bwtCode;
		free(countValue);
	}

	BWT()
	{
		bwtCode = NULL;
		saValue = NULL;
		
		saLength = 0;
		textLength = 0;

		bwtSizeInWord = 0;
		occSizeInWord = 0;
		saValueSizeInWord = 0;
	}*/
};


	
void DecodeBWT(BWT* bwt, unsigned int *tempBwtCode);
void Initialize(BWT* bwt,unsigned int bwtLength);
void getSaValue(unsigned int left, unsigned int right, unsigned int * saValue);

unsigned int BWTResidentSizeInWord(unsigned int textLength);
unsigned int BWTFileSizeInWord(unsigned int textLength);
unsigned int BWTOccValueMinorSizeInWord(const unsigned int numChar);
unsigned int BWTOccValueMajorSizeInWord(const unsigned int numChar);
void BWTClearTrailingBwtCode(BWT* bwt);
//void printCount();


#endif
